package net.midnighttd.game.view;

import net.midnighttd.engine.entity.Entity;
import net.midnighttd.game.entity.Tower;

import javax.swing.*;
import java.awt.*;

/**
 * Author: Adam Scarr
 * Date: 21/04/2009
 * Time: 6:03:22 PM
 */
public class EntityInspector extends JPanel {
    private JPanel oldPanel;

    public EntityInspector() {
        setLayout(new BorderLayout());
        setBackground(new Color(73, 86, 63));

        add(spacer(), BorderLayout.NORTH);
        add(spacer(), BorderLayout.SOUTH);
        add(spacer(), BorderLayout.EAST);
        add(spacer(), BorderLayout.WEST);

        oldPanel = new JPanel();
       // add(oldPanel, BorderLayout.CENTER);
    }

    public JComponent spacer() {
        JComponent spacer = new JPanel();
        spacer.setBackground(new Color(73, 86, 63));
        return spacer;
    }


    public void displayEntityDetails(MainUI ui, Entity entity) {

        System.out.println("Updating inspector details with new entity " + entity.getName());
        remove(oldPanel);

        if(entity.getType().equals("tower")) {
            oldPanel = new TowerDetail(ui, (Tower)entity);
        } else {
            oldPanel = new EntityDetail(entity);
        }

        add(oldPanel, BorderLayout.CENTER);

        revalidate();
        //repaint();

    }
}
